package main

import (
	"fmt"
	"hardware_test/init/config"
	"hardware_test/init/viper"
	"hardware_test/utils/common"
	myzap "hardware_test/utils/zap"
)

var (
	gitBranch  string
	gitCommit  string
	gitVersion string
)

func printVersion() {
	myzap.Logger.Infof("------------------------------------------------------------")
	myzap.Logger.Infof("- BuildDate:\t%s", common.GetBuildDate())
	myzap.Logger.Infof("- GitBranch:\t%s", gitBranch)
	myzap.Logger.Infof("- GitCommit:\t%s", gitCommit)
	myzap.Logger.Infof("- GitVersion:\t%s", gitVersion)
	myzap.Logger.Infof("- Version: \t%s", common.GetVersion())
	myzap.Logger.Infof("------------------------------------------------------------")
}

func main() {
	fmt.Println("Cloud chint app start!")
	viper.InitViper()
	config.InitConfig() //preload config
	config.ConnectStatus = "Unknown"
	logConf := &config.CONFIG.Log
	myzap.InitLogger(logConf.FileName, logConf.FileLevel,
		logConf.FileMaxSize, logConf.FileMaxBackups,
		logConf.FileMaxAge, logConf.FileCompress, logConf.ConsoleLevel)
	defer myzap.Logger.Sync()
	printVersion()
}
